package ru.urfc.portal.ui.client.controllers;

import ru.urfc.portal.ui.client.controllers.loaders.ConfigurableLoader;
import ru.urfc.portal.ui.client.controllers.loaders.SimpleLoader;
import ru.urfc.portal.ui.client.descriptor.GridDescriptor;

import com.extjs.gxt.ui.client.data.LoadEvent;
import com.extjs.gxt.ui.client.event.LoadListener;

public abstract class SimpleItemsController extends ItemsController {
	
	SimpleLoader loader; 
	
	public SimpleItemsController(GridDescriptor descriptor) {
		super(descriptor);
	}

	@Override
	protected ConfigurableLoader<?> createLoader(GridDescriptor descriptor) {
		loader = new SimpleLoader();
		loader.addLoadListener(new LoadListener() {
			@Override
			public void loaderLoad(LoadEvent event) {
				onUpdate(event.getData());
			}
		});
		return loader;
	}	
	
	public SimpleLoader getSimpleLoader() {
		return loader;
	}
	
	public abstract void onUpdate(Object data);
	
}
